<?php

class MY_Controller extends CI_Controller {
    public $_layout = 'page';
    public $theme = 'sunny';
    /**
     * Class constructor
     *
     * @return	void
     */
    public function __construct() {
        parent::__construct();
        //read more here
        // http://ellislab.com/codeigniter/user-guide/general/controllers.html
        $this->load->set_theme($this->theme);
       
//         // Get theme from database and set it
//        $theme_name = $this->settings->theme;
//        $this->load->set_theme($theme_name);
        //http://ellislab.com/forums/viewthread/142062/
        //http://ellislab.com/forums/viewthread/142044/
        define('AJAX_REQUEST',	$this->input->is_ajax_request());
        //is_cli_request
       
    }

    public function _output($output) {
        //handle for template
        if (AJAX_REQUEST) {
            echo $output; exit;
        }
        
        $this->load->layout('page_' . strtolower(get_class($this)), array('content' => $output));
    }
    /*
    public function _remap($method, $params = array()) {
        
        
        print_r($method);
        print_r($params);
        echo __CLASS__; 
        
        echo get_called_class();
        echo get_class();
        echo get_class($this);
        
        
        if ($method == 'hello') {
            echo 'hello world'; exit;
        }
        
        exit;
        
        $method = 'process_' . $method;
        if (method_exists($this, $method)) {
            return call_user_func_array(array($this, $method), $params);
        }
        
        
        
        if ($method == 'index')
        {
            echo 'this is index page'; exit;
        }
        else
        {
            echo 'This is default method'; exit;
        }
        
        
        show_404();
    }*/

}
/**
 * controller for backend
 */
class ACP_Controller extends MY_Controller {
    public $_layout = 'page';
    public $theme = 'admin';
     /**
     * Class constructor
     *
     * @return	void
     */
    public function __construct() {
        parent::__construct();
    }
}
